package rmi;


import java.awt.Image;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

import javax.swing.ImageIcon;

public class Question implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	public static final int MAX_PRIORITY = 5;
	public static final int MIN_PRIORITY = 1;
	private int questionID;
	private String questionContent;
	private String questionImageLink;
	private int questionType;
	private LinkedHashMap<Integer, Answer> mapAnswers;
	private int priority;
	
	public Question() {
		this.mapAnswers = new LinkedHashMap<>();
	}
	
	public void setChosenAnswer(int answerID){
		for(Entry<Integer, Answer> e : this.mapAnswers.entrySet()){
			if(answerID == (e.getKey().intValue())){
				//this.strChosenAnswerID = e.getKey();
			}
		}
	}
	
	public boolean setPriority(int priority){
		if(priority<= MAX_PRIORITY && priority>= MIN_PRIORITY){
			this.priority = priority;
			return true;
		}
		return false;
	}
	
	public int getPriority(){
		return this.priority;
	}

	public int getQuestionID() {
		return this.questionID;
	}

	public void setQuestionID(int questionID) {
		this.questionID = questionID;
	}

	public String getQuestion() {
		return questionContent;
	}

	public void setQuestion(String questionContent) {
		this.questionContent = questionContent;
	}

	public int getQuestionType() {
		return questionType;
	}

	public void setQuestionType(int questionType) {
		this.questionType = questionType;
	}

	public LinkedHashMap<Integer, Answer> getMapAnswers() {
		return mapAnswers;
	}
	
	public void setMapAnswers(LinkedHashMap<Integer, Answer> mapAnswers) {
		this.mapAnswers = mapAnswers;
	}

	@Override
	public String toString() {
		String temp = questionContent;
		return temp;
	}

	public String getQuestionImageLink() {
		return questionImageLink;
	}

	public void setQuestionImageLink(String questionImageLink) {
		this.questionImageLink = questionImageLink;
	}

	public Image getQuestionImage() {
		if(questionImageLink == null){
			Image im = (new ImageIcon(questionImageLink)).getImage();
			return im;
		}else{
			return null;
		}
		
		
	}
}
